﻿#region

using System;
using System.Deployment.Application;
using System.Reflection;
using System.Windows.Forms;
using MidnightPeach.Properties;

#endregion

namespace MidnightPeach.Components
{
    public static class GeneralUtility
    {
        /// <summary>
        ///   버전 정보를 얻는다. (클릭원스로 배포되었으면 게시 버전)
        /// </summary>
        /// <returns></returns>
        public static Version GetVersion()
        {
            return (ApplicationDeployment.IsNetworkDeployed)
                       ? ApplicationDeployment.CurrentDeployment.CurrentVersion
                       : Assembly.GetEntryAssembly().GetName().Version;
        }

        public static string GetVersionText()
        {
            Version version = GetVersion();

            return string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build);
        }

        public static void CopyToClipboard(string generatedCode)
        {
            // It must be cleared before copying mass data to clipboard. I don't know why.
            Clipboard.Clear();
            Clipboard.SetText(generatedCode, TextDataFormat.Text);
            
            MessageBox.Show(Resources.Copied);
        }
    }
}